package com.lx.demo.core.config;

import com.alibaba.dubbo.config.spring.ReferenceBean;
import com.lx.demo.b.interfaces.TestDemoBDubboService;
import com.lx.demo.core.constant.Commonsts;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by lanyxp on 2021/2/23 10:35
 * 推荐使用 com.alibaba.dubbo.config.annotation.Reference注解
 * Apache Dubbo 不推荐使用 ReferenceBean<T> 进行消费初始化服务引用
 * {@link com.alibaba.dubbo.config.annotation.Reference}
 */
@Deprecated
@Configuration
public class DubboConfig {
    private <T> ReferenceBean createReferenceBean(Class<T> interfanceclass) {
        ReferenceBean referenceBean = new ReferenceBean();
        referenceBean.setInterface(interfanceclass);
        referenceBean.setCheck(Boolean.FALSE);
        referenceBean.setOwner(Commonsts.DUBO_OWNER);
        referenceBean.setTimeout(Commonsts.DUBO_TIME);
        referenceBean.setGroup(Commonsts.DUBO_GROUP);
        referenceBean.setVersion(Commonsts.DUBO_VERSION);
        return referenceBean;
    }
    /***
     * 配置Dubbo服务B
     * @return
     */
    @Bean
    public ReferenceBean<TestDemoBDubboService> testDemoBDubboServiceReferenceBean() {
        return this.createReferenceBean(TestDemoBDubboService.class);
    }
}
